﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="majandusaasta_aruanded_rea_veerg", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MajandusaastaAruandedReaVeerg))]
    public class MajandusaastaAruandedReaVeergSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMajandusaastaAruandedReaVeerg clazz;
        
        public MajandusaastaAruandedReaVeergSerializer(IMajandusaastaAruandedReaVeerg clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("veeru_kood");
            if (clazz.VeeruKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.VeeruKood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : VeeruKood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("veeru_nimetus");
            if (clazz.VeeruNimetus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.VeeruNimetus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : VeeruNimetus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("vaartus");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Vaartus))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="veeru_kood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>majandusaasta_aruanded_rea_veerg>veeru_kood");
                }
                clazz.VeeruKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("veeru_kood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>majandusaasta_aruanded_rea_veerg>veeru_kood", Reader.LocalName);
            }
            if (Reader.LocalName=="veeru_nimetus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>majandusaasta_aruanded_rea_veerg>veeru_nimetus");
                }
                clazz.VeeruNimetus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("veeru_nimetus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>majandusaasta_aruanded_rea_veerg>veeru_nimetus", Reader.LocalName);
            }
            if (Reader.LocalName=="vaartus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>majandusaasta_aruanded_rea_veerg>vaartus");
                }
                clazz.Vaartus = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("vaartus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>majandusaasta_aruanded_rea_veerg>vaartus", Reader.LocalName);
            }
        }
    }
}
